//
//  PersonSectionController.m
//  MY_IGList_demo
//
//  Created by mac on 2019/3/19.
//  Copyright © 2019 Yilian. All rights reserved.
//

#import "PersonSectionController.h"
#import "PersonCollectionViewCell.h"
#import "PersonModel.h"
@interface PersonSectionController()

@property (nonatomic, strong) PersonModel *model;

@end
@implementation PersonSectionController

- (instancetype)init {
    if (self = [super init]) {
        
        self.inset = UIEdgeInsetsMake(0, 0, 1, 0);
//        self.displayDelegate = self;
    }
    return self;
}

- (NSInteger)numberOfItems{
    return 1;
}

- (CGSize)sizeForItemAtIndex:(NSInteger)index{
    if (self.model.name.length > 10) {
        return CGSizeMake([[UIScreen mainScreen] bounds].size.width/3 -1,[[UIScreen mainScreen] bounds].size.width/2 - 1);
    }else{
        return CGSizeMake([[UIScreen mainScreen] bounds].size.width/3 -1,[[UIScreen mainScreen] bounds].size.width/3 - 1);
    }
    
}

- (__kindof UICollectionViewCell *)cellForItemAtIndex:(NSInteger)index{
    
    PersonCollectionViewCell *cell = [self.collectionContext dequeueReusableCellWithNibName:@"PersonCollectionViewCell" bundle:nil forSectionController:self atIndex:index];
    
    [cell setCellWithModel:self.model];
    return cell;
}

- (void)didUpdateToObject:(id)object{
    self.model = object;
}

- (void)didSelectItemAtIndex:(NSInteger)index{
    NSLog(@"%ld ",self.section);
    if (self.section == 0) {
        NSLog(@"////%ld ",self.section);
        self.viewController.navigationController.navigationBar.alpha = .0;
        [self.viewController.navigationController.navigationBar setHidden:NO];
    }else if(self.section == 2){
        [self.viewController.navigationController.navigationBar setHidden:NO];
        self.viewController.navigationController.navigationBar.alpha = 1.0;
        self.viewController.navigationController.navigationBar.shadowImage = [UIImage new];
        self.viewController.navigationController.navigationBar.backgroundColor = [UIColor blueColor];
    }else{
        [self.viewController.navigationController.navigationBar setHidden:YES];
    }
}
@end
